package com.mandao.concurrency.example.singleton;

import com.mandao.concurrency.annotations.NotRecommend;
import com.mandao.concurrency.annotations.NotThreadSafe;
import com.mandao.concurrency.annotations.ThreadSafe;

/**
 *  懒汉式
 *      单例实例在第一次使用时创建
 *
 *      性能开销
 */
@ThreadSafe
@NotRecommend
public class SingletonExample3 {
    private SingletonExample3(){}

    private static SingletonExample3 instance = null;

    public static synchronized SingletonExample3 getInstance(){
        if (null == instance){
            instance = new SingletonExample3();
        }
        return instance;
    }
}
